/**
 * @author Shenn
 * 
 */

import grid.gridClient.Mersenne_Prime_Search;
import java.io.*;
import java.util.Date;

public class TestMPS {

    public static void main(String[] args) {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
        int startP = 0, endP = 0;
        
        try {
            System.out.print("Start: ");
            String st = br.readLine();
            if (st.length() != 0) startP = Integer.parseInt(st);
            
            System.out.print("end: ");
            String en = br.readLine();
            endP = Integer.parseInt(en);
            
            Mersenne_Prime_Search mps = new Mersenne_Prime_Search(); 
    		Date startDate = new Date();
    		Date endDate = new Date();

    		System.out.println("MPS started.");
    		System.out.println("From " + startP + " to " + endP);
    		startDate.setTime(System.currentTimeMillis());
    		System.out.println("Start: " + startDate);
    		System.out.println("Computing");
    		
    		mps.genPrimeList(startP, endP);
    		System.out.println("Gen PrimeList Done.");
    		for (int i=0; i<mps.PrimeList.length; i++) {
    		    if (mps.LucasLehmerTesting(mps.PrimeList[i])) {
    		        System.out.println("2^" + mps.PrimeList[i] + "-1");
    		    }
    		}
    		
    		endDate.setTime(System.currentTimeMillis());
    		System.out.println("\nEnd: " + endDate);
    		long spanSeconds = (endDate.getTime() - startDate.getTime())/1000;
    		System.out.println("Spends " + spanSeconds + " Seconds.");
			
    		System.out.println("Press Enter to continue...");
			System.in.read();
        } catch (Exception ex) {
            ex.printStackTrace();
    		System.out.println("Press Enter to continue...");
    		try {
    		    System.in.read();
    		} catch (IOException ioe) {}
        }
    }
}
